package com.epichust.bootumpp.controller;

import com.epichust.bootumpp.config.NotIntercept;
import com.epichust.bootumpp.model.bo.ReturnBO;
import com.epichust.bootumpp.model.entity.Umpp5ProRouteLine;
import com.epichust.bootumpp.service.IUmpp5ProRouteLineService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author ：longyang
 * @date ：Created in 2021/1/7 13:58
 * @description：产品工艺路线controller
 *
 */
@RestController
@RequestMapping("api/proRouteLine")
public class Umpp5ProRouteLineController {

    @Autowired
    private IUmpp5ProRouteLineService iUmpp5ProRouteLineService;

    /**
     * 分页查询产品工艺路线
     * @param map
     * @return
     */
    @RequestMapping(value = "/getAll", method = {RequestMethod.POST})
    @NotIntercept
    public String getAllUmpp5ProRouteLine(@RequestBody Map<String,Object> map){
        try{
            // 新建返回对象
            Gson gson = new GsonBuilder().serializeNulls().create();
            ReturnBO bo = new ReturnBO();
            List<Umpp5ProRouteLine> list = iUmpp5ProRouteLineService.getAllUmpp5ProRouteLine(map);
            bo.setState(0);
            bo.setObject(list);
            return gson.toJson(bo);
        }catch (Exception e){
            // 新建返回对象
            Gson gson = new GsonBuilder().serializeNulls().create();
            ReturnBO bo = new ReturnBO();
            bo.setState(1);
            bo.setObject("查询失败："+e.getMessage());
            e.printStackTrace();
            return gson.toJson(bo);
        }
    }
}
